home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPBAR.ZIP / APPKEYB.C < prev    next >
C/C++ Source or Header  |  1993-06-04  |  3KB  |  104 lines

  1. /* appkeyb.c */
  2.  
  3. /*
  4.    functions for AppBar's keyboard interface
  5. */
  6.  
  7. #define STRICT
  8. #include <windows.h>
  9. #include <windowsx.h>
  10. #include <string.h>
  11. #include "appbar.h"
  12.  
  13. int KeyboardInterface(int key)
  14.     {
  15.     switch(key)
  16.     {
  17.     case VK_ESCAPE:
  18.         if(!bKeyboardOn)
  19.         {
  20.         bKeyboardOn = TRUE;    // turn keyb interface on
  21.         iKey = iCurrent = 0;
  22.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  23.         UpdateWindow(hWndButton[iCurrent]);
  24.         }
  25.         else
  26.         {
  27.         bKeyboardOn = FALSE;    // turn keyb interface off
  28.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  29.         UpdateWindow(hWndButton[iCurrent]);
  30.         }
  31.         return 0;
  32.  
  33.     case VK_DELETE:
  34.         if(bKeyboardOn)
  35.         SendMessage(hWndMain, WM_COMMAND, ID_BUTTON1+iCurrent, MAKELPARAM(0, BN_DOUBLECLICKED));
  36.         return 0;
  37.  
  38.     case VK_RETURN:
  39.         if(bKeyboardOn)
  40.         SendMessage(hWndMain, WM_COMMAND, ID_BUTTON1+iCurrent, MAKELPARAM(0, BN_CLICKED));
  41.         return 0;
  42.  
  43.     case VK_UP:
  44.         if(bKeyboardOn)
  45.         {
  46.         bKeyboardOn = FALSE;
  47.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  48.         UpdateWindow(hWndButton[iCurrent]);
  49.         iCurrent = max(0, iCurrent-1);
  50.         iKey = iCurrent;
  51.         bKeyboardOn = TRUE;
  52.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  53.         UpdateWindow(hWndButton[iCurrent]);
  54.         }
  55.         return 0;
  56.  
  57.     case VK_DOWN:
  58.         if(bKeyboardOn)
  59.         {
  60.         bKeyboardOn = FALSE;
  61.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  62.         UpdateWindow(hWndButton[iCurrent]);
  63.         iCurrent++;
  64.         iCurrent = min(AppWindow.nButtons-1, iCurrent);
  65.         iKey = iCurrent;
  66.         bKeyboardOn = TRUE;
  67.         InvalidateRect(hWndButton[iCurrent], (LPRECT) NULL, FALSE);
  68.         UpdateWindow(hWndButton[iCurrent]);
  69.         }
  70.         return 0;
  71.  
  72.     default:
  73.         return 0;
  74.     }
  75.     }
  76.  
  77. /*-------------------------------------------------------------------------*/
  78. int ProcessSystemKeys(int SysKey)
  79.     {
  80.     static DLGPROC lpfnExitWDlgProc;
  81.  
  82.     switch(SysKey)
  83.     {
  84.     case VK_F4:        // ALT-F4 pressed, close if not shell,
  85.         if(!IsAppBarShell())     // exit windows if shell.
  86.         {
  87.         if(AppSound.EnableSound != 0)
  88.             if(stricmp(AppSound.AppBarExit, "<none>") != 0)
  89.             sndPlaySound(AppSound.AppBarExit, SND_ASYNC | SND_NODEFAULT);
  90.         SendMessage(hWndMain, WM_DESTROY, 0, 0);
  91.         }
  92.          else
  93.         {
  94.         lpfnExitWDlgProc = (DLGPROC) MakeProcInstance((FARPROC)ExitWDlgProc, hInst);
  95.         DialogBox(hInst, "ExitWDlg", hWndMain, lpfnExitWDlgProc);
  96.         FreeProcInstance((FARPROC)lpfnExitWDlgProc);
  97.         }
  98.          return 0;
  99.  
  100.     default:
  101.          return 0;
  102.     }
  103.     }
  104.